#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)  
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

int _,n;
//9 1001
//8 1000

int main(){
	std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("in.in", "r", stdin);
	cin >> _;
	while(_--){
		cin >> n;
		int tmp = n / 4 + !(n % 4 == 0);
		per(i,n,tmp+1) cout << 9;
		per(i,tmp,1) cout << 8;
		cout << "\n";
	}
	return 0;
}